package leetcode_201_300;

import node.Node;
import node.TreeNode;

import java.util.ArrayList;
import java.util.List;

public class LeeCode_257 {
    public static void main(String[] args) {

    }
    private static List<String> binaryTreePaths(TreeNode root) {
        List<String> ans = new ArrayList<>();
        if (root != null){
            f(root, root.val + "", ans);
        }
        return ans;
    }
    private static void f(TreeNode node, String s, List<String> ans){
        if (node.left == null && node.right == null){
            ans.add(s);
            return;
        }
        if (node.left != null){
            String newS = s + "->" + node.left.val;
            f(node.left, newS, ans);
        }
        if (node.right != null){
            String newS = s + "->" + node.right.val;
            f(node.right, newS, ans);
        }
    }
}
